package com.ruoyi.controller;

import com.ruoyi.domain.SpaceRecord;
import com.ruoyi.platform.annotation.Log;
import com.ruoyi.platform.core.controller.BaseController;
import com.ruoyi.platform.core.domain.AjaxResult;
import com.ruoyi.platform.core.page.TableDataInfo;
import com.ruoyi.platform.enums.BusinessType;
import com.ruoyi.platform.utils.poi.ExcelUtil;
import com.ruoyi.service.ISpaceRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 智联空间文档操作记录Controller
 *
 * @author ruoyi
 * @date 2022-12-19
 */
@RestController
@RequestMapping("/admin/record")
@Api(tags = {"智联空间文档操作记录服务"})
public class SpaceRecordController extends BaseController {

    @Autowired
    private ISpaceRecordService spaceRecordService;

    /**
     * 查询智联空间文档操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('admin:record:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询智联空间文档操作记录列表", httpMethod = "GET", notes = "查询智联空间文档操作记录列表")
    public TableDataInfo list(SpaceRecord spaceRecord) {
        startPage();
        List<SpaceRecord> list = spaceRecordService.selectSpaceRecordList(spaceRecord);
        return getDataTable(list);
    }

    /**
     * 导出智联空间文档操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('admin:record:export')")
    @Log(title = "智联空间文档操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出智联空间文档操作记录列表", httpMethod = "POST", notes = "导出智联空间文档操作记录列表")
    public void export(HttpServletResponse response, SpaceRecord spaceRecord) {
        List<SpaceRecord> list = spaceRecordService.selectSpaceRecordList(spaceRecord);
        ExcelUtil<SpaceRecord> util = new ExcelUtil<>(SpaceRecord.class);
        util.exportExcel(response, list, "智联空间文档操作记录数据");
    }

    /**
     * 获取智联空间文档操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:record:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取智联空间文档操作记录详细信息", httpMethod = "GET", notes = "获取智联空间文档操作记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(spaceRecordService.selectSpaceRecordById(id));
    }

    /**
     * 新增智联空间文档操作记录
     */
    @PreAuthorize("@ss.hasPermi('admin:record:add')")
    @Log(title = "智联空间文档操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增智联空间文档操作记录", httpMethod = "POST", notes = "新增智联空间文档操作记录")
    public AjaxResult add(@RequestBody SpaceRecord spaceRecord) {
        return toAjax(spaceRecordService.insertSpaceRecord(spaceRecord));
    }

    /**
     * 修改智联空间文档操作记录
     */
    @PreAuthorize("@ss.hasPermi('admin:record:edit')")
    @Log(title = "智联空间文档操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改智联空间文档操作记录", httpMethod = "PUT", notes = "修改智联空间文档操作记录")
    public AjaxResult edit(@RequestBody SpaceRecord spaceRecord) {
        return toAjax(spaceRecordService.updateSpaceRecord(spaceRecord));
    }

    /**
     * 删除智联空间文档操作记录
     */
    @PreAuthorize("@ss.hasPermi('admin:record:remove')")
    @Log(title = "智联空间文档操作记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除智联空间文档操作记录", httpMethod = "DELETE", notes = "删除智联空间文档操作记录")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(spaceRecordService.deleteSpaceRecordByIds(ids));
    }


}
